<?php 
class PanelWidget extends CWidget
{
	public function run()
	{
		$this->getUserPanel();
	}
	protected function getUserPanel()
	{
		//Get user authenticated.
		$user = User::model()->findByAttributes(array('username'=>Yii::app()->user->id));
		if(isset($user->id))
		{
		//$data = Yii::app()->user->getState('user');
            //print_r($user->id);die('die here');
			$data = User::model()->findByPk($user->id);
			$this->render('panel',array('data' => $data));
		}
		else{
			$this->render('panel');
		}
		//Check User authenticated.
		// if (strpos($_SERVER['REQUEST_URI'],'/admin/') !== false) {
		// 	if(isset($user['id']) && $user['roles_id'] == 1)
		// 	{
		// 		// $data = Yii::app()->user->getState('user');
		// 		$data = User::model()->findByPk($user['id']);
		// 		$this->render('panel',array('data' => $data));
		// 	}
		// 	else{
		// 		$this->render('panel');
		// 	}
		// }else{
		// 	if(isset($user['id']) && $user['roles_id'] == 0)
		// 	{
		// 		// $data = Yii::app()->user->getState('user');
		// 		$data = User::model()->findByPk($user['id']);
		// 		$this->render('panel',array('data' => $data));
		// 	}
		// 	else{
		// 		$this->render('panel');
		// 	}

		// }
		
	}
}
?>